{{extend "layout_admin.html"}}

{{block css}}{{end}}

{{block title}}
<i class="fa fa-user fa-fw"></i> 用户管理
{{end}}

{{block content}}
<div class="row">
    <div class="col-lg-3">
        <button type="button" class="btn btn-primary btn-lg" id="btn-add-user"><span class="fa fa-plus fa-fw"></span> 追加新用户</button>
    </div>
    <div class="col-lg-3">
        <div class="input-group">
            <input type="text" class="form-control" id="txt-search-name" value="{{=search_name}}" placeholder="用户名">
            <span class="input-group-btn">
                <button class="btn btn-default" type="button" id="btn-search">
                    <span class="glyphicon glyphicon-search"></span> 检索</button>
            </span>
        </div><!-- /input-group -->
        <p class="help-block">模糊检索 - 用户登录名或者用户真实姓名</p>
    </div>
</div>
<br>
<div class="row">
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <th>#ID</th>
                <th>用户名</th>
                <th>真实姓名</th>
                <th>电子邮箱</th>
                <th>电话号码</th>
                <th>删除</th>
            </tr>
        </thead>
        <tbody>
            {{for user in users:}}
            <tr>
                <td><a href="/admin/edit-user/{{=user.id}}">{{=user.id}}</a></td>
                <td>{{=user.name}}</td>
                <td>{{=user.real_name}}</td>
                <td>{{=user.email}}</td>
                <td>{{=user.telephone}}</td>
                <td>
                    <button class="btn btn-danger btn-xs" onclick="del_user({{=user.id}});"><i class="fa fa-trash-o fa-fw"></i>删除</button>
                </td>
            </tr>
            {{pass}}
        </tbody>
    </table>
</div>

{{end}}

{{block js}}
<script src="{{=url_for_static('chujue-js/chujue_validate.js')}}"></script>
<script src="{{=url_for_static('chujue-js/chujue_ajax.js')}}"></script>
<script type="text/javascript" src="{{=url_for_static('views_user_admin/list.js')}}"></script>

<script type="text/javascript">
    $(function(){
        $("#btn-add-user").click(function() {
            location.href = "/admin/edit-user/0";
        });

        $("#btn-search").click(function() {
            if ($("#txt-search-name").val() == "")
                location.href = "/admin/user-list";
            else
                location.href = "/admin/user-list/" + $("#txt-search-name").val();
        });
    });
</script>
{{end}}

